<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>数字toFixed方法</title>
</head>

<body>
  <script>
    // ============================== 数字 toFixed 方法 ==============================
    // 数字 toFixed 方法
    const num = 12.345
    console.log(num.toFixed(2)) // 12.35  四舍五入
    console.log(num.toFixed(1)) // 12.3

    const num1 = 12
    console.log(num1.toFixed(2)) // 12.00

  </script>
</body>

</html>